<html>
<head><meta charset="utf-8"><title>Less red in the code · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Less.20red.20in.20the.20code.html">Less red in the code</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="205001130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Less%20red%20in%20the%20code/near/205001130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Less.20red.20in.20the.20code.html#205001130">(Jul 25 2020 at 11:59)</a>:</h4>
<p>Is there any way to adjust the missing field highlighting?<br>
Sometimes it looks a bit too verbose IMO:<br>
<a href="/user_uploads/4715/plJHCpl6d2S4fRu4MjjNAYOZ/image.png">image.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/plJHCpl6d2S4fRu4MjjNAYOZ/image.png" title="image.png"><img src="/user_uploads/4715/plJHCpl6d2S4fRu4MjjNAYOZ/image.png"></a></div>



<a name="205002003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Less%20red%20in%20the%20code/near/205002003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Less.20red.20in.20the.20code.html#205002003">(Jul 25 2020 at 12:25)</a>:</h4>
<p>It would be nice if the span pointed to a comma or something</p>



<a name="205004248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Less%20red%20in%20the%20code/near/205004248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mr Smeet <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Less.20red.20in.20the.20code.html#205004248">(Jul 25 2020 at 13:37)</a>:</h4>
<p>Complex design issue. The problem really in object declaration. But rust declaration unordered. Maybe good solution show shadowy field like "seven: unknown" with error underline or another approach we can show shadowy tip text of enumeration missed fields</p>



<a name="205004415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Less%20red%20in%20the%20code/near/205004415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Less.20red.20in.20the.20code.html#205004415">(Jul 25 2020 at 13:42)</a>:</h4>
<p>I fail to understand how the highlight range is derived in the code itself, if somebody is able to shed some light there, I can provide some design input later.</p>



<a name="205005071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Less%20red%20in%20the%20code/near/205005071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mr Smeet <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Less.20red.20in.20the.20code.html#205005071">(Jul 25 2020 at 14:01)</a>:</h4>
<p>Vs code use monaco editor <a href="https://microsoft.github.io/monaco-editor/playground.html#interacting-with-the-editor-line-and-inline-decorations">https://microsoft.github.io/monaco-editor/playground.html#interacting-with-the-editor-line-and-inline-decorations</a> . RA use also decorations <a href="https://github.com/rust-analyzer/rust-analyzer/blob/master/editors/code/src/inlay_hints.ts">https://github.com/rust-analyzer/rust-analyzer/blob/master/editors/code/src/inlay_hints.ts</a> so I think squiggles are kind of decorator too</p>



<a name="205005202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Less%20red%20in%20the%20code/near/205005202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Less.20red.20in.20the.20code.html#205005202">(Jul 25 2020 at 14:05)</a>:</h4>
<p>The range is fetched from the body's SourceMap. It's the range of the whole record literal expression.</p>



<a name="205005393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Less%20red%20in%20the%20code/near/205005393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Less.20red.20in.20the.20code.html#205005393">(Jul 25 2020 at 14:10)</a>:</h4>
<p>(<code>create_record_literal_missing_fields_diagnostic</code> is what creates the diagnostics, it's called with the <code>ExprId</code> of the record literal expression and looks it up in the <code>SourceMap</code>)</p>



<a name="205008782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Less%20red%20in%20the%20code/near/205008782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Less.20red.20in.20the.20code.html#205008782">(Jul 25 2020 at 15:38)</a>:</h4>
<p>Thanks for the pointer.</p>
<p>I wonder how do we manage to handle the missing field range differently and not highlight the whole declaration <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span><br>
Hope I'll find the answers soon.</p>



<a name="205043081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Less%20red%20in%20the%20code/near/205043081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Less.20red.20in.20the.20code.html#205043081">(Jul 26 2020 at 08:51)</a>:</h4>
<p>Yes, we should more targeted highlighting here (the same for missing arg inspection). Though, the rage for the fix should be the whole struct literal. So, we need to have two ranges somewhere...</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>